package com.qcdp.utils;

import com.qcdp.entity.User;

public class UserHolderVersion1 {
    private static final ThreadLocal<User> tl = new ThreadLocal<>();
    //保存当前用户到线程变量当中
    public static void saveUser(User user){
        tl.set(user);
    }
    //获取当前线程的用户信息
    public static User getUser(){
        return tl.get();
    }

    //移除当前线程中的用户信息
    public static void removeUser(){
        tl.remove();
    }
}
